home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Internet Tools 1993 July / Internet Tools.iso / RockRidge / mail / sendmail / sendmail-5.65c+IDA-1.4.4.1 / src / RCS / collect.c,v < prev    next >
Encoding:
Text File  |  1991-06-25  |  16.9 KB  |  928 lines

  1. head    5.9;
  2. branch    5.9.0;
  3. access;
  4. symbols
  5.     RELEASE:5.9.0.14
  6.     BETA:5.9.0.13
  7.     UICSO:5.9.0
  8.     VANILLA:5.9;
  9. locks; strict;
  10. comment    @ * @;
  11.  
  12.  
  13. 5.9
  14. date    90.06.20.08.35.25;    author paul;    state Exp;
  15. branches
  16.     5.9.0.1;
  17. next    ;
  18.  
  19. 5.9.0.1
  20. date    90.06.20.09.42.35;    author paul;    state Exp;
  21. branches;
  22. next    5.9.0.2;
  23.  
  24. 5.9.0.2
  25. date    90.11.28.16.27.30;    author paul;    state Exp;
  26. branches;
  27. next    5.9.0.3;
  28.  
  29. 5.9.0.3
  30. date    91.02.01.04.49.26;    author paul;    state Exp;
  31. branches;
  32. next    5.9.0.4;
  33.  
  34. 5.9.0.4
  35. date    91.02.17.03.49.25;    author paul;    state Exp;
  36. branches;
  37. next    5.9.0.5;
  38.  
  39. 5.9.0.5
  40. date    91.03.04.21.48.23;    author paul;    state Exp;
  41. branches;
  42. next    5.9.0.6;
  43.  
  44. 5.9.0.6
  45. date    91.03.05.16.46.48;    author paul;    state Exp;
  46. branches;
  47. next    5.9.0.7;
  48.  
  49. 5.9.0.7
  50. date    91.03.05.23.04.43;    author paul;    state Exp;
  51. branches;
  52. next    5.9.0.8;
  53.  
  54. 5.9.0.8
  55. date    91.04.05.06.33.33;    author paul;    state Exp;
  56. branches;
  57. next    5.9.0.9;
  58.  
  59. 5.9.0.9
  60. date    91.04.05.14.55.15;    author paul;    state Exp;
  61. branches;
  62. next    5.9.0.10;
  63.  
  64. 5.9.0.10
  65. date    91.04.30.16.44.59;    author paul;    state Exp;
  66. branches;
  67. next    5.9.0.11;
  68.  
  69. 5.9.0.11
  70. date    91.05.20.22.31.10;    author paul;    state Exp;
  71. branches;
  72. next    5.9.0.12;
  73.  
  74. 5.9.0.12
  75. date    91.05.21.17.27.50;    author paul;    state Exp;
  76. branches;
  77. next    5.9.0.13;
  78.  
  79. 5.9.0.13
  80. date    91.05.29.19.36.13;    author paul;    state Exp;
  81. branches;
  82. next    5.9.0.14;
  83.  
  84. 5.9.0.14
  85. date    91.06.21.12.37.55;    author paul;    state Exp;
  86. branches;
  87. next    ;
  88.  
  89.  
  90. desc
  91. @@
  92.  
  93.  
  94. 5.9
  95. log
  96. @5.64 Berkeley release
  97. @
  98. text
  99. @/*
  100.  * Copyright (c) 1983 Eric P. Allman
  101.  * Copyright (c) 1988 Regents of the University of California.
  102.  * All rights reserved.
  103.  *
  104.  * Redistribution and use in source and binary forms are permitted provided
  105.  * that: (1) source distributions retain this entire copyright notice and
  106.  * comment, and (2) distributions including binaries display the following
  107.  * acknowledgement:  ``This product includes software developed by the
  108.  * University of California, Berkeley and its contributors'' in the
  109.  * documentation or other materials provided with the distribution and in
  110.  * all advertising materials mentioning features or use of this software.
  111.  * Neither the name of the University nor the names of its contributors may
  112.  * be used to endorse or promote products derived from this software without
  113.  * specific prior written permission.
  114.  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
  115.  * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
  116.  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  117.  */
  118.  
  119. #ifndef lint
  120. static char sccsid[] = "@@(#)collect.c    5.9 (Berkeley) 6/1/90";
  121. #endif /* not lint */
  122.  
  123. # include <errno.h>
  124. # include "sendmail.h"
  125.  
  126. /*
  127. **  COLLECT -- read & parse message header & make temp file.
  128. **
  129. **    Creates a temporary file name and copies the standard
  130. **    input to that file.  Leading UNIX-style "From" lines are
  131. **    stripped off (after important information is extracted).
  132. **
  133. **    Parameters:
  134. **        sayok -- if set, give an ARPANET style message
  135. **            to say we are ready to collect input.
  136. **
  137. **    Returns:
  138. **        none.
  139. **
  140. **    Side Effects:
  141. **        Temp file is created and filled.
  142. **        The from person may be set.
  143. */
  144.  
  145. collect(sayok)
  146.     bool sayok;
  147. {
  148.     register FILE *tf;
  149.     char buf[MAXFIELD], buf2[MAXFIELD];
  150.     register char *workbuf, *freebuf;
  151.     register int workbuflen;
  152.     extern char *hvalue();
  153.     extern bool isheader(), flusheol();
  154.  
  155.     /*
  156.     **  Create the temp file name and create the file.
  157.     */
  158.  
  159.     CurEnv->e_df = newstr(queuename(CurEnv, 'd'));
  160.     if ((tf = dfopen(CurEnv->e_df, "w")) == NULL)
  161.     {
  162.         syserr("Cannot create %s", CurEnv->e_df);
  163.         NoReturn = TRUE;
  164.         finis();
  165.     }
  166.     (void) chmod(CurEnv->e_df, FileMode);
  167.  
  168.     /*
  169.     **  Tell ARPANET to go ahead.
  170.     */
  171.  
  172.     if (sayok)
  173.         message("354", "Enter mail, end with \".\" on a line by itself");
  174.  
  175.     /*
  176.     **  Try to read a UNIX-style From line
  177.     */
  178.  
  179.     if (sfgets(buf, MAXFIELD, InChannel) == NULL)
  180.         goto readerr;
  181.     fixcrlf(buf, FALSE);
  182. # ifndef NOTUNIX
  183.     if (!SaveFrom && strncmp(buf, "From ", 5) == 0)
  184.     {
  185.         if (!flusheol(buf, InChannel))
  186.             goto readerr;
  187.         eatfrom(buf);
  188.         if (sfgets(buf, MAXFIELD, InChannel) == NULL)
  189.             goto readerr;
  190.         fixcrlf(buf, FALSE);
  191.     }
  192. # endif NOTUNIX
  193.  
  194.     /*
  195.     **  Copy InChannel to temp file & do message editing.
  196.     **    To keep certain mailers from getting confused,
  197.     **    and to keep the output clean, lines that look
  198.     **    like UNIX "From" lines are deleted in the header.
  199.     */
  200.  
  201.     workbuf = buf;        /* `workbuf' contains a header field */
  202.     freebuf = buf2;        /* `freebuf' can be used for read-ahead */
  203.     for (;;)
  204.     {
  205.         /* first, see if the header is over */
  206.         if (!isheader(workbuf))
  207.         {
  208.             fixcrlf(workbuf, TRUE);
  209.             break;
  210.         }
  211.  
  212.         /* if the line is too long, throw the rest away */
  213.         if (!flusheol(workbuf, InChannel))
  214.             goto readerr;
  215.  
  216.         /* it's okay to toss '\n' now (flusheol() needed it) */
  217.         fixcrlf(workbuf, TRUE);
  218.  
  219.         workbuflen = strlen(workbuf);
  220.  
  221.         /* get the rest of this field */
  222.         for (;;)
  223.         {
  224.             if (sfgets(freebuf, MAXFIELD, InChannel) == NULL)
  225.                 goto readerr;
  226.  
  227.             /* is this a continuation line? */
  228.             if (*freebuf != ' ' && *freebuf != '\t')
  229.                 break;
  230.  
  231.             if (!flusheol(freebuf, InChannel))
  232.                 goto readerr;
  233.  
  234.             /* yes; append line to `workbuf' if there's room */
  235.             if (workbuflen < MAXFIELD-3)
  236.             {
  237.                 register char *p = workbuf + workbuflen;
  238.                 register char *q = freebuf;
  239.  
  240.                 /* we have room for more of this field */
  241.                 fixcrlf(freebuf, TRUE);
  242.                 *p++ = '\n'; workbuflen++;
  243.                 while(*q != '\0' && workbuflen < MAXFIELD-1)
  244.                 {
  245.                     *p++ = *q++;
  246.                     workbuflen++;
  247.                 }
  248.                 *p = '\0';
  249.             }
  250.         }
  251.  
  252.         CurEnv->e_msgsize += workbuflen;
  253.  
  254.         /*
  255.         **  The working buffer now becomes the free buffer, since
  256.         **  the free buffer contains a new header field.
  257.         **
  258.         **  This is premature, since we still havent called
  259.         **  chompheader() to process the field we just created
  260.         **  (so the call to chompheader() will use `freebuf').
  261.         **  This convolution is necessary so that if we break out
  262.         **  of the loop due to H_EOH, `workbuf' will always be
  263.         **  the next unprocessed buffer.
  264.         */
  265.  
  266.         {
  267.             register char *tmp = workbuf;
  268.             workbuf = freebuf;
  269.             freebuf = tmp;
  270.         }
  271.  
  272.         /*
  273.         **  Snarf header away.
  274.         */
  275.  
  276.         if (bitset(H_EOH, chompheader(freebuf, FALSE)))
  277.             break;
  278.     }
  279.  
  280.     if (tTd(30, 1))
  281.         printf("EOH\n");
  282.  
  283.     if (*workbuf == '\0')
  284.     {
  285.         /* throw away a blank line */
  286.         if (sfgets(buf, MAXFIELD, InChannel) == NULL)
  287.             goto readerr;
  288.     }
  289.     else if (workbuf == buf2)    /* guarantee `buf' contains data */
  290.         (void) strcpy(buf, buf2);
  291.  
  292.     /*
  293.     **  Collect the body of the message.
  294.     */
  295.  
  296.     do
  297.     {
  298.         register char *bp = buf;
  299.  
  300.         fixcrlf(buf, TRUE);
  301.  
  302.         /* check for end-of-message */
  303.         if (!IgnrDot && buf[0] == '.' && (buf[1] == '\n' || buf[1] == '\0'))
  304.             break;
  305.  
  306.         /* check for transparent dot */
  307.         if (OpMode == MD_SMTP && !IgnrDot && bp[0] == '.' && bp[1] == '.')
  308.             bp++;
  309.  
  310.         /*
  311.         **  Figure message length, output the line to the temp
  312.         **  file, and insert a newline if missing.
  313.         */
  314.  
  315.         CurEnv->e_msgsize += strlen(bp) + 1;
  316.         fputs(bp, tf);
  317.         fputs("\n", tf);
  318.         if (ferror(tf))
  319.             tferror(tf);
  320.     } while (sfgets(buf, MAXFIELD, InChannel) != NULL);
  321.  
  322. readerr:
  323.     if (fflush(tf) != 0)
  324.         tferror(tf);
  325.     (void) fclose(tf);
  326.  
  327.     /* An EOF when running SMTP is an error */
  328.     if ((feof(InChannel) || ferror(InChannel)) && OpMode == MD_SMTP)
  329.     {
  330.         int usrerr(), syserr();
  331. # ifdef LOG
  332.         if (RealHostName != NULL && LogLevel > 0)
  333.             syslog(LOG_NOTICE,
  334.                 "collect: unexpected close on connection from %s: %m\n",
  335.                 CurEnv->e_from.q_paddr, RealHostName);
  336. # endif
  337.         (feof(InChannel) ? usrerr: syserr)
  338.             ("collect: unexpected close, from=%s", CurEnv->e_from.q_paddr);
  339.  
  340.         /* don't return an error indication */
  341.         CurEnv->e_to = NULL;
  342.         CurEnv->e_flags &= ~EF_FATALERRS;
  343.  
  344.         /* and don't try to deliver the partial message either */
  345.         finis();
  346.     }
  347.  
  348.     /*
  349.     **  Find out some information from the headers.
  350.     **    Examples are who is the from person & the date.
  351.     */
  352.  
  353.     eatheader(CurEnv);
  354.  
  355.     /*
  356.     **  Add an Apparently-To: line if we have no recipient lines.
  357.     */
  358.  
  359.     if (hvalue("to") == NULL && hvalue("cc") == NULL &&
  360.         hvalue("bcc") == NULL && hvalue("apparently-to") == NULL)
  361.     {
  362.         register ADDRESS *q;
  363.  
  364.         /* create an Apparently-To: field */
  365.         /*    that or reject the message.... */
  366.         for (q = CurEnv->e_sendqueue; q != NULL; q = q->q_next)
  367.         {
  368.             if (q->q_alias != NULL)
  369.                 continue;
  370.             if (tTd(30, 3))
  371.                 printf("Adding Apparently-To: %s\n", q->q_paddr);
  372.             addheader("apparently-to", q->q_paddr, CurEnv);
  373.         }
  374.     }
  375.  
  376.     if ((CurEnv->e_dfp = fopen(CurEnv->e_df, "r")) == NULL)
  377.         syserr("Cannot reopen %s", CurEnv->e_df);
  378. }
  379. /*
  380. **  FLUSHEOL -- if not at EOL, throw away rest of input line.
  381. **
  382. **    Parameters:
  383. **        buf -- last line read in (checked for '\n'),
  384. **        fp -- file to be read from.
  385. **
  386. **    Returns:
  387. **        FALSE on error from sfgets(), TRUE otherwise.
  388. **
  389. **    Side Effects:
  390. **        none.
  391. */
  392.  
  393. bool
  394. flusheol(buf, fp)
  395.     char *buf;
  396.     FILE *fp;
  397. {
  398.     char junkbuf[MAXLINE], *sfgets();
  399.     register char *p = buf;
  400.  
  401.     while (index(p, '\n') == NULL) {
  402.         if (sfgets(junkbuf,MAXLINE,fp) == NULL)
  403.             return(FALSE);
  404.         p = junkbuf;
  405.     }
  406.  
  407.     return(TRUE);
  408. }
  409. /*
  410. **  TFERROR -- signal error on writing the temporary file.
  411. **
  412. **    Parameters:
  413. **        tf -- the file pointer for the temporary file.
  414. **
  415. **    Returns:
  416. **        none.
  417. **
  418. **    Side Effects:
  419. **        Gives an error message.
  420. **        Arranges for following output to go elsewhere.
  421. */
  422.  
  423. tferror(tf)
  424.     FILE *tf;
  425. {
  426.     if (errno == ENOSPC)
  427.     {
  428.         (void) freopen(CurEnv->e_df, "w", tf);
  429.         fputs("\nMAIL DELETED BECAUSE OF LACK OF DISK SPACE\n\n", tf);
  430.         usrerr("452 Out of disk space for temp file");
  431.     }
  432.     else
  433.         syserr("collect: Cannot write %s", CurEnv->e_df);
  434.     (void) freopen("/dev/null", "w", tf);
  435. }
  436. /*
  437. **  EATFROM -- chew up a UNIX style from line and process
  438. **
  439. **    This does indeed make some assumptions about the format
  440. **    of UNIX messages.
  441. **
  442. **    Parameters:
  443. **        fm -- the from line.
  444. **
  445. **    Returns:
  446. **        none.
  447. **
  448. **    Side Effects:
  449. **        extracts what information it can from the header,
  450. **        such as the date.
  451. */
  452.  
  453. # ifndef NOTUNIX
  454.  
  455. char    *DowList[] =
  456. {
  457.     "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat", NULL
  458. };
  459.  
  460. char    *MonthList[] =
  461. {
  462.     "Jan", "Feb", "Mar", "Apr", "May", "Jun",
  463.     "Jul", "Aug", "Sep", "Oct", "Nov", "Dec",
  464.     NULL
  465. };
  466.  
  467. eatfrom(fm)
  468.     char *fm;
  469. {
  470.     register char *p;
  471.     register char **dt;
  472.  
  473.     if (tTd(30, 2))
  474.         printf("eatfrom(%s)\n", fm);
  475.  
  476.     /* find the date part */
  477.     p = fm;
  478.     while (*p != '\0')
  479.     {
  480.         /* skip a word */
  481.         while (*p != '\0' && *p != ' ')
  482.             p++;
  483.         while (*p == ' ')
  484.             p++;
  485.         if (!isupper(*p) || p[3] != ' ' || p[13] != ':' || p[16] != ':')
  486.             continue;
  487.  
  488.         /* we have a possible date */
  489.         for (dt = DowList; *dt != NULL; dt++)
  490.             if (strncmp(*dt, p, 3) == 0)
  491.                 break;
  492.         if (*dt == NULL)
  493.             continue;
  494.  
  495.         for (dt = MonthList; *dt != NULL; dt++)
  496.             if (strncmp(*dt, &p[4], 3) == 0)
  497.                 break;
  498.         if (*dt != NULL)
  499.             break;
  500.     }
  501.  
  502.     if (*p != NULL)
  503.     {
  504.         char *q;
  505.         extern char *arpadate();
  506.  
  507.         /* we have found a date */
  508.         q = xalloc(25);
  509.         (void) strncpy(q, p, 25);
  510.         q[24] = '\0';
  511.         define('d', q, CurEnv);
  512.         q = arpadate(q);
  513.         define('a', newstr(q), CurEnv);
  514.     }
  515. }
  516.  
  517. # endif NOTUNIX
  518. @
  519.  
  520.  
  521. 5.9.0.1
  522. log
  523. @IDA patches
  524. @
  525. text
  526. @d94 1
  527. a94 1
  528. # endif /* NOTUNIX */
  529. d238 1
  530. a238 1
  531. # endif /* LOG */
  532. d419 1
  533. a419 1
  534. # endif /* NOTUNIX */
  535. @
  536.  
  537.  
  538. 5.9.0.2
  539. log
  540. @Add (char) cast to NULL comparison.
  541. @
  542. text
  543. @d404 1
  544. a404 1
  545.     if (*p != (char) NULL)
  546. @
  547.  
  548.  
  549. 5.9.0.3
  550. log
  551. @Added fsync() calls before close of df and cf files.  Helps prevent lost
  552. mail on a system that's crashing often.  Depending on performance lossage
  553. and portability constraints, this may need #ifdef PARANOID later.
  554. @
  555. text
  556. @a226 1
  557.     (void) fsync(fileno(tf));
  558. @
  559.  
  560.  
  561. 5.9.0.4
  562. log
  563. @Added static keyword to declarations for tferror(), flusheol(), eatfrom().
  564. @
  565. text
  566. @d55 1
  567. a55 3
  568.     extern bool isheader();
  569.     static bool flusheol();
  570.     static tferror(), eatfrom();;
  571. d296 1
  572. a296 1
  573. static bool
  574. a325 1
  575. static
  576. a369 1
  577. static
  578. @
  579.  
  580.  
  581. 5.9.0.5
  582. log
  583. @ANSIfied.
  584. @
  585. text
  586. @d25 2
  587. a26 2
  588. #include <errno.h>
  589. #include "sendmail.h"
  590. a27 10
  591. #ifdef __STDC__
  592. static bool flusheol(const char *, FILE *);
  593. static void tferror(FILE *);
  594. static void eatfrom(const char *);
  595. #else /* !__STDC__ */
  596. static bool flusheol();
  597. static void tferror();
  598. static void eatfrom();
  599. #endif /* __STDC__ */
  600.  
  601. a46 1
  602. void
  603. d54 4
  604. d235 1
  605. d300 1
  606. a300 1
  607.     const char *buf;
  608. d303 2
  609. a304 2
  610.     char junkbuf[MAXLINE];
  611.     register const char *p = buf;
  612. d328 1
  613. a328 1
  614. static void
  615. d373 1
  616. a373 1
  617. static void
  618. d375 1
  619. a375 1
  620.     const char *fm;
  621. d377 1
  622. a377 1
  623.     register const char *p = fm;
  624. d384 1
  625. d412 1
  626. @
  627.  
  628.  
  629. 5.9.0.6
  630. log
  631. @Put overly long headers (> 500 bytes) at end of message body.  Adapted
  632. from Paul Vixie's patch.
  633. @
  634. text
  635. @d236 2
  636. a237 5
  637.     
  638.     /*
  639.      * Since overly long headers are appended to the end of the message
  640.      * body, delay closing tf until eatheader is done.
  641.      */
  642. a249 1
  643.         (void) fclose(tf);
  644. d264 1
  645. a264 5
  646.     eatheader(CurEnv, tf);
  647.  
  648.     /* Now close the tf file */
  649.     (void) fsync(fileno(tf));
  650.     (void) fclose(tf);
  651. @
  652.  
  653.  
  654. 5.9.0.7
  655. log
  656. @Too many broken compilers out there that can't handle functions in
  657. conditional statements.
  658. @
  659. text
  660. @d251 2
  661. a252 12
  662.         /*
  663.          * So many broken compilers out there...
  664.          * (feof(InChannel) ? usrerr: syserr)
  665.          *    ("collect: unexpected close, from=%s",
  666.          *        CurEnv->e_from.q_paddr);
  667.          */
  668.         if (feof(InChannel))
  669.             usrerr("collect: unexpected close, from=%s",
  670.                 CurEnv->e_from.q_paddr);
  671.         else
  672.             syserr("collect: unexpected close, from=%s",
  673.                 CurEnv->e_from.q_paddr);
  674. @
  675.  
  676.  
  677. 5.9.0.8
  678. log
  679. @Character set translation changes adapted from patches from Keld Simonsen
  680. (keld@@dkuug.dk).
  681. @
  682. text
  683. @a64 5
  684. #ifdef BIT8
  685.     char buf1[MAXFIELD+2];
  686.     CHARSET *ch;
  687.     char *chname, *chesc;
  688. #endif /* BIT8 */
  689. a206 11
  690. # ifdef BIT8
  691.     chname = hvalue("x-charset");
  692.     chesc = hvalue("x-char-esc");
  693.     if (!chesc)
  694.         chesc = "29";
  695.     if (chname)
  696.         ch = getchset(chname, atoi(chesc));
  697.     else
  698.         ch = CurEnv->e_from.q_mailer->m_charset;
  699. # endif /* BIT8 */
  700.  
  701. a210 8
  702. # ifdef BIT8
  703.         if (ch)
  704.         {
  705.             strncnv(ch, ascii, (CHAR8U *)buf1, (CHAR8U *)buf, sizeof buf1);
  706.             strncpy(buf, buf1, sizeof buf);
  707.         }
  708. # endif /* BIT8 */
  709.  
  710. d330 1
  711. a330 2
  712.     while (index(p, '\n') == NULL)
  713.     {
  714. d332 1
  715. a332 1
  716.             return (FALSE);
  717. d336 1
  718. a336 1
  719.     return (TRUE);
  720. @
  721.  
  722.  
  723. 5.9.0.9
  724. log
  725. @Added RCS ID string
  726. @
  727. text
  728. @a22 1
  729. static char rcsid[] = "@@(#)$Id$";
  730. @
  731.  
  732.  
  733. 5.9.0.10
  734. log
  735. @Had first two arguments to strncnv() reversed.
  736. @
  737. text
  738. @d23 1
  739. a23 1
  740. static char rcsid[] = "@@(#)$Id: collect.c,v 5.9.0.9 1991/04/05 14:55:15 paul Exp paul $";
  741. d231 1
  742. a231 1
  743.             strncnv(ascii, ch, (CHAR8U *)buf1, (CHAR8U *)buf, sizeof buf1);
  744. @
  745.  
  746.  
  747. 5.9.0.11
  748. log
  749. @fsync() now done only if SuperSafe is set.
  750. @
  751. text
  752. @d22 2
  753. a23 2
  754. static char sccsid[] = "@@(#)collect.c    5.9 (Berkeley) 6/1/90    %I% local";
  755. static char rcsid[] = "@@(#)$Id: collect.c,v 5.9.0.10 1991/04/30 16:44:59 paul Exp paul $";
  756. d99 1
  757. a99 1
  758. #ifndef NOTUNIX
  759. d109 1
  760. a109 1
  761. #endif /* NOTUNIX */
  762. d213 1
  763. a213 1
  764. #ifdef BIT8
  765. d222 1
  766. a222 11
  767. #endif /* BIT8 */
  768. #ifdef SYSV
  769.     if (SuperSafe)
  770.     {
  771.         int fd = fileno(tf);
  772.         int flags;
  773.  
  774.         if ((flags = fcntl(fd, F_GETFL)) != -1)
  775.             (void) fcntl(fd, F_SETFL, flags | O_SYNC);
  776.     }
  777. #endif /* SYSV */
  778. d228 1
  779. a228 1
  780. #ifdef BIT8
  781. d234 1
  782. a234 1
  783. #endif /* BIT8 */
  784. d270 1
  785. a270 1
  786. #ifdef LOG
  787. d275 1
  788. a275 1
  789. #endif /* LOG */
  790. d306 1
  791. a306 4
  792. #ifndef SYSV
  793.     if (SuperSafe)
  794.         (void) fsync(fileno(tf));
  795. #endif /* !SYSV */
  796. d409 1
  797. a409 1
  798. #ifndef NOTUNIX
  799. d472 1
  800. a472 1
  801. #endif /* NOTUNIX */
  802. @
  803.  
  804.  
  805. 5.9.0.12
  806. log
  807. @Simplified collection of header and body, eliminated goto readerr.  Part of
  808. the System 5 and general improvement patches contributed by Bruce Lilly
  809. (bruce@@broadcast.sony.com).
  810. @
  811. text
  812. @d23 1
  813. a23 1
  814. static char rcsid[] = "@@(#)$Id: collect.c,v 5.9.0.11 1991/05/20 22:31:10 paul Exp paul $";
  815. d30 1
  816. d34 1
  817. d63 3
  818. a65 2
  819.     char buf[MAXFIELD+2];
  820.     register char *p;
  821. d96 2
  822. a97 6
  823.     /*
  824.      * Read errors here are caught inside the do loop.  sfgets() will
  825.      * set buf[0] to NULL and fixcrlf() will return immediately because
  826.      * of that.
  827.      */
  828.     (void) sfgets(buf, sizeof buf, InChannel);
  829. d102 2
  830. d105 2
  831. a106 1
  832.         (void) sfgets(buf, sizeof buf, InChannel);
  833. a115 1
  834.     **    (See above)
  835. d118 8
  836. a125 5
  837.     do {
  838.         int c;
  839.  
  840.         /* drop out on error */
  841.         if (ferror(InChannel))
  842. d127 1
  843. d130 5
  844. a134 6
  845.         if (index(buf, '\n') == NULL)
  846.         {
  847.             while ((c = getc(InChannel)) != '\n' && c != EOF)
  848.                 continue;
  849.         }
  850.         fixcrlf(buf, TRUE);
  851. d136 1
  852. a136 3
  853.         /* see if the header is over */
  854.         if (!isheader(buf))
  855.             break;
  856. d139 1
  857. a139 1
  858.         while ((c = getc(InChannel)) == ' ' || c == '\t')
  859. d141 5
  860. a145 4
  861.             p = &buf[strlen(buf)];
  862.             *p++ = '\n';
  863.             *p++ = c;
  864.             if (sfgets(p, sizeof(buf) - (p - buf), InChannel) == NULL)
  865. d147 20
  866. a166 1
  867.             fixcrlf(p, TRUE);
  868. a167 2
  869.         if (!feof(InChannel) && !ferror(InChannel))
  870.             (void) ungetc(c, InChannel);
  871. d169 19
  872. a187 1
  873.         CurEnv->e_msgsize += strlen(buf);
  874. d193 1
  875. a193 1
  876.         if (bitset(H_EOH, chompheader(buf, FALSE)))
  877. d195 1
  878. a195 1
  879.     } while (sfgets(buf, sizeof(buf) - 2, InChannel) != NULL);
  880. d200 8
  881. a207 3
  882.     /* throw away a blank line */
  883.     if (buf[0] == '\0' && !ferror(InChannel))
  884.         (void) sfgets(buf, sizeof(buf), InChannel);
  885. a237 3
  886.         /* drop out on error */
  887.         if (ferror(InChannel))
  888.             break;
  889. d266 1
  890. a266 1
  891.     } while (sfgets(buf, sizeof(buf), InChannel) != NULL);
  892. d268 1
  893. d283 1
  894. a283 1
  895.                 "collect: unexpected close on connection from %s: %m",
  896. d345 31
  897. @
  898.  
  899.  
  900. 5.9.0.13
  901. log
  902. @Removed #ifndef NOTUNIX around Dow strings (needed in arpatounix())
  903. @
  904. text
  905. @d23 1
  906. a23 1
  907. static char rcsid[] = "@@(#)$Id: collect.c,v 5.9.0.12 1991/05/21 17:27:50 paul Exp paul $";
  908. d350 2
  909. a362 2
  910.  
  911. #ifndef NOTUNIX
  912. @
  913.  
  914.  
  915. 5.9.0.14
  916. log
  917. @Deleted extraneous parameter from syslog() call.
  918. @
  919. text
  920. @d22 2
  921. a23 2
  922. static char sccsid[] = "@@(#)collect.c    5.9 (Berkeley) 6/1/90";
  923. static char rcsid[] = "@@(#)$Id: collect.c,v 5.9.0.13 1991/05/29 19:36:13 paul Exp paul $";
  924. d243 1
  925. a243 1
  926.                 RealHostName);
  927. @
  928.